<?php

/**
 * Displays a "Add Feedback form".
 *
 * @package    mahara
 * @subpackage artefact-feedback
 * @author     laurent.opprecht@gmail.com
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
 * @copyright  (C) 2011 University of Geneva http://www.unige.ch/
 *
 */
define('INTERNAL', 1);
define('MENUITEM', 'myportfolio');

require(dirname(dirname(dirname(__FILE__))) . '/init.php');
safe_require('artefact', 'feedback');

/**
 * CACHE.
 * The add form does not change so it can be cached.
 * Headers must be set after init.
 *
 */
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
    $modified = filemtime(__FILE__);
    header('Last-Modified: ' . date('r', $modified));
    header('Cache-Control: max-age=1, must-revalidate');
}

if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $_SERVER['REQUEST_METHOD'] == 'GET') {
    $cache_date = strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']);
    $modified_date = filemtime(__FILE__);
    if($modified_date <= $cache_date){
        header('HTTP/1.1 304 Not Modified');
        exit;
    }
}

/**
 * End of CACHE.
 */

$title = get_string('addfeedback', 'artefact.feedback');
$description = '';

$parent_id = param_integer('parent_id');
$view_id = param_integer('view_id', 0);
$goto = $view_id ? get_config('wwwroot') . '/view/view.php?id=' . $view_id: '';
$form = add_parentfeedback_form::create($parent_id, $goto);

$headers = PluginArtefactFeedback::get_headers();



$smarty = smarty(array(), $headers);
$smarty->assign('PAGEHEADING', $title);
$smarty->assign('description', $description);
$smarty->assign('form', $form);
$smarty->display('artefact:feedback:add.tpl');


?>
